﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace EWDTAssignment
{
    public partial class LiveChat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["AccountID"] = 1;
            if (!IsPostBack)
            {
                Session["Time"] = DateTime.Now;
            }
            DateTime d = Convert.ToDateTime(Session["Time"]);
            //DataTable dt=App_Code.LiveChatSQL.uploadMessage(1, d);
            //DataTable dt = App_Code.LiveChatSQL.uploadMessage(1, d);
            DataTable newdt = App_Code.LiveChatLogic.Upload(App_Code.LiveChatSQL.uploadMessage(1, d));
            
            GridView2.DataSource = newdt;
            GridView2.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            int id;
            if ((int)Session["AccountID"] != 0)
            {
                 id = (int)Session["AccountID"];
            }
            else
            {
                id = 0;
            }
            int staffid = 3;
            string message = ChatMsgTbx.Text;
            DateTime time = DateTime.Now;
            string type = "Customer";
            int a = 0;
            a=App_Code.LiveChatSQL.Say(id, staffid, time, message, type);
            ChatMsgTbx.Text = "";
        }

    }
}